﻿using Core.CSV;
using Core.Interface;
using Prism.Ioc;
using Prism.Modularity;
using System.Windows;
using System;

namespace CSVData
{
    public class CSVDataModule : IModule
    {
        public void OnInitialized(IContainerProvider containerProvider)
        {
            try
            {
                //IContainerProvider：框架从容器中拿对象
                var csv = containerProvider.Resolve<ICSVDataHelper>("CSV");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }          
        }
        //注册类型
        public void RegisterTypes(IContainerRegistry containerRegistry)
        {
            try
            {
                //IContainerRegistry：注册对象、类型到容器
                //containerRegistry.Register<ICSVDataHelper, CSVDataHelper>();
                //containerRegistry.RegisterSingleton<ICSVDataHelper, CSVDataHelper>();
                //containerRegistry.RegisterInstance<ICSVDataHelper>(new CSVDataHelper(), "CSV");
                ICSVDataHelper csv = new CSVDataHelper();
                csv.FileFolder = "CSV";
                csv.AutoName = true;
                csv.Title = "时间,压力值";
                csv.HowManyDays = 15;
                csv.Init();
                containerRegistry.RegisterInstance(csv, "CSV");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }       
        }
    }
}

